import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export const createAutoImport = () => {
  return [
    AutoImport({
      //需要去解析的需要用到自动引入的文件
      include: [
        /\.[tj]sx?$/, //.ts,.tsx,.js,.jsx
        /\.vue$/,
        /\.vue\?vue/, //.vue
        /\.md$/ //.md
      ],
      //imports指定自动引入的包名
      imports: ['vue', 'pinia', 'vue-router'], //生成相应的自动导入json文件。
      eslintrc: {
        //启用
        enabled: false, //生成自动导入json文件位置
        filepath: './.eslintrc-auto-import.json', //全局属性值
        globalsPropValue: true
      },
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      //imports指定组件所在目录，默认为src/components
      dirs: ['src/components/', 'src/views/'],
      //需要去解析的文件
      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
      resolvers: [ElementPlusResolver()]
    })
  ]
}
